// // 引入路由组件
// // import Home from '@/pages/Home'
// // import Login from '@/pages/Login'
// import RegLister from '@/pages/RegLister'
// // import Search from '@/pages/Search'
// import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import Center from '@/pages/Center'
import Communication from '@/pages/Communication'
// // 引入二级路由组件
import MyOrder from '@/pages/Center/myOrder'
import GroupOrder from '@/pages/Center/groupOrder'
import Event from '@/pages/Communication/Event'
import ModelTest from '@/pages/Communication/ModelTest'
import SyncTest from '@/pages/Communication/SyncTest'
import AttrsListenersTest from '@/pages/Communication/AttrsListenersTest'
// 路由配置信息
export default [
    {
        path: '/home',
        component: () => import('@/pages/Home'),
        meta: { show: true }
    },
    {
        path: '/search/:keyword?',
        component: () => import('@/pages/Search'),
        meta: { show: true },
        name: 'search',
        //路由组件传递props数据
        // 布尔值
        // props: true
        // 对象:额外的给props传递一些参数
        // props: { a: 1, b: 2 }
        // 函数:可以让params参数,query参数,通过props传递给路由组件
        props: (route) => ({ keyWord: route.params.keyWord, k: route.query.k })
    },
    {
        path: '/login',
        component: () => import('@/pages/Login'),
        meta: { show: false }
    },
    {
        path: '/reglister',
        component: () => import('@/pages/RegLister'),
        meta: { show: false }
    },
    {
        path: '/detail/:skuId',
        component: () => import('@/pages/Detail'),
        meta: { show: true }
    },
    {
        path: '/addcartsuccess',
        name: 'addcartsuccess',
        component: AddCartSuccess,
        meta: { show: true }
    },
    {
        path: '/shopcart',
        component: ShopCart,
        meta: { show: true }
    },
    {
        path: '/trade',
        component: Trade,
        meta: { show: true },
        beforeEnter: (to, from, next) => {
            // 要想去交易页面,必须是从购物车而来
            if (from.path == '/shopcart') {
                next()
            } else {
                // 是从其他路由组件而来,停留在当前页面
                next(false)
            }
        }
    },
    {
        path: '/pay',
        component: Pay,
        meta: { show: true },
        beforeEnter: (to, from, next) => {
            if (from.path == '/trade') {
                next()
            } else {
                next(false)
            }
        }
    },
    {
        path: '/paysuccess',
        component: PaySuccess,
        meta: { show: true }
    },

    {
        path: '/center',
        component: Center,
        meta: { show: true },
        // 二级路由组件
        children: [
            { path: 'myorder', component: MyOrder },
            { path: 'grouporder', component: GroupOrder },
            { path: '/center', redirect: '/center/myorder' }
        ]
    },
    {
        path: '/communication',
        component: Communication,
        meta: { show: true },
        children: [
            { path: 'event', component: Event },
            { path: 'moduletest', component: ModelTest },
            { path: 'synctest', component: SyncTest },
            { path: 'attrslistenerstest', component: AttrsListenersTest }
        ]
    },
    {
        // 重定向：在项目跑起来的时候,访问/,立马让他定向到首页
        path: '*',
        redirect: '/home'
    },

]